package com.lanou.controller;

import com.lanou.bean.ReclamationOrder;
import com.lanou.bean.ScrapCollector;
import com.lanou.service.ScrapCollectorService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;


@RestController
public class ScrapConController {

    @Autowired
    private ScrapCollectorService scrapCollectorService;

    //手机绑定绑定微信
    @RequestMapping("/toBindingWeixin")
    public int toBindingWeixin(String date){
        System.out.println("获取到openid和电话的信息--------"+date);
        String[] split = date.split("/");
        ScrapCollector scrapCollector=new ScrapCollector();
        scrapCollector.setOpenid(split[0]);
        scrapCollector.setTel(split[1]);
        System.out.println("插入数据库的信息-------"+scrapCollector);
        int result = scrapCollectorService.updateByTel(scrapCollector);
        System.out.println("返回的更新结果-----"+result);
        return result;
    }


    @RequestMapping("/editOrder")
    public int editOrder(String data){
        System.out.println("获取到data信息"+data);
        String[] split = data.split("/");
        ReclamationOrder reclamationOrder=new ReclamationOrder();
        reclamationOrder.setOrderNo(split[0]);
        if(split[1].equals("")){
            reclamationOrder.setAmount(0);
        }
        if(split[2].equals("")){
            reclamationOrder.setMoney(0);
        }
        reclamationOrder.setScStatus(split[3]);
        reclamationOrder.setUpdateTime(new Date());
        System.out.println("传过去的订单信息----------"+reclamationOrder);
        int result = scrapCollectorService.editOrder(reclamationOrder);
        System.out.println("返回的结果---------"+result);
        return result;
    }


}
